<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="vue.js" type="text/javascript" charset="utf-8"></script>
</head>
<body>
    <div id="app">
       <input type="button" value="+" @click="add">
       <span>{{ message }}</span>
       <input type="button" value="-" @click="sub">
    </div>
    <script>
        // var message = { a:1 };
       var vm = new Vue({
           el:"#app",
           data:{
             message:0
           },
           methods: {
              jia:function(){
                this.message=this.message+1;
                if(this.message>10){
                    alert("超过10");
                    this.message=10; 
                    return this.message;
                }
              }, 
              jian:function(){
                this.message=this.message-1;
                if(this.message<0){
                    alert("数字小于0");
                    this.message=0;
                    return this.message;
                }
               },
               add:function(){
                   if(this.message<10){
                       this.message++;
                   }else{
                       alert("别点了,最大了！");
                   }
               },
               sub:function(){
                   if(this.message>0){
                       this.message--;
                   }else{
                       alert("别点了,最小了！");
                   }
               }
           }
       });
    </script>
</body>
</html>